package medium最多水的容器;

import org.testng.annotations.Test;

public class Solution {
    public int maxArea(int[] height) {
        int max = -1;
        for (int i = 0,j = height.length-1; i < j; ) {

            if (height[i]<height[j]){
                if ((j-i)*height[i]>max)
                    max = (j-i)*height[i];
            }

            else {
                if ((j - i) * height[j] > max)
                    max = (j - i) * height[j];
            }
            if (height[i]>height[j])
                j--;
            else
                i++;
        }
        return max;
    }

    @Test
    public void test(){
        int[] height = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(height));
    }
}
